package main.java.facade;

/**
 * 外观类 暴露给用户的类
 */
public class SmartAppliancesFacade {
    private Light light;
    private Tv tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new Tv();
        airCondition = new AirCondition();
    }

    /**
     * 语音控制
     * @param message
     */
    public void say(String message){
        if(message.contains("打开")){
            on();
        }else if(message.contains("关闭")){
            off();
        }else{
            System.out.println("听不懂说啥");
        }

    }

    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }

    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }
}
